import { Module, Global } from '@nestjs/common';
import { DbService } from './db.service';
import { TypegooseModule } from 'nestjs-typegoose'
import { User } from '@libs/db/models/user.model'
import { Course } from '@libs/db/models/course.model'
import { Episode } from '@libs/db/models/episode.model'
import { Action } from './models/action.model';


const models = TypegooseModule.forFeature([User,Course,Episode,Action])

@Global()
@Module({
  imports:[
    TypegooseModule.forRoot('mongodb://localhost:topfullstack',{
      useFindAndModify:false,
      useNewUrlParser:true,
      useCreateIndex:true,
      useUnifiedTopology:true,
    }),
    models
  ],
  providers: [DbService],
  exports: [DbService,models],
})
export class DbModule {}
